package chat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class ClientTest1 {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("192.168.1.132", 8080);
//获得键盘输入
        BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
//获得基于Socket的输入流和输出流
        PrintWriter os = new PrintWriter(socket.getOutputStream());
        BufferedReader is = new BufferedReader(new InputStreamReader(
                socket.getInputStream()));
        String readline;
        System.out.println("客户端启动完毕，等待输入：");
        readline = sin.readLine();
//向服务器写数据
        new Thread(new ClientListener(socket)).start();//监听服务器反馈信息
        while (!readline.equals("exit")) {
            os.println(readline);
            os.flush();
            readline = sin.readLine();
        }
    }
}
